* Measure news coverage of each mass shooting

clear all
set more off

loc days = 10

use "in-data/nonfam_shootings.dta", clear

isid fips date
keep fips usps date fatalities

egen int event = group(fips date)
expand `days'
bys event: replace date = date + (_n - 1)

merge m:1 date using "out-data/gun_news.dta" /*
    */ , assert(2 3) keep(3) nogen keepusing(duration)

collapse (min) date (sum) news=duration (max) max_news=duration /*
    */ (mean) avg_news=duration, by(event fips usps) fast

la var event "A unique shooting event identifier"
la var usps "State abbreviation"
la var date "Shooting date"
la var news "Total seconds news coverage, days [0, `days')"
la var max_news "Max seconds news coverage, days [0, `days')"
la var avg_news "Mean seconds news coverage, days [0, `days')"

qui compress
la data "News coverage by shooting"
save "out-data/news_by_shooting.dta", replace
exit
